<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>非受控组件</title>
</head>
<body>
<div id="container">

</div>
</body>
</html>


<!--引入react核心库-->
<script type="text/javascript" src="../Js/react.development.js"></script>
<!--引入react-dom库,用于支持react操作dom-->
<script type="text/javascript" src="../Js/react-dom.development.js"></script>
<!--引入babel库,用于将jsx转成js-->
<script type="text/javascript" src="../Js/babel.min.js"></script>
<!--引入prop-types库,用于将对props进行类型限制-->
<script type="text/javascript" src="../Js/prop-types.js"></script>

<script type="text/babel">//此处一定要写text/babel，将jsx转成js

class Demo extends React.Component{

    showData=(e)=>{
        e.preventDefault()//阻止表单提交
        alert(`账号:${this.account.value},密码:${this.password.value}`)
    }

    render(){
        return (
            <div>
                <form action="https://www.baidu.com/">
                    <label >账号</label><input type="text" ref={c=>this.account=c}/>
                    <label >密码</label> <input type="password" ref={c=>this.password=c}/>
                    <button onClick={this.showData}>登录</button>
                </form>
            </div>
        )
    }
}

ReactDOM.render(<Demo/>,document.getElementById("container"))

</script>